Tutorial for Data Exploration Tool - Lantern Part 1
Overview¶
Lantern is a python module for a toolkit collection for data exploration from a variety of dataset to visualization.
In this post, I will walk through the followings:
- How to set up
lantern - What
lanterncan do- dataset
- plot (visualization)
- grid (interactive table view)
- widget
How to set up Lantern¶
In [90]:
# !pip install pylantern
# !jupyter labextension install pylantern # for jupyter lab
In [21]:
import lantern as l
import matplotlib.pyplot as plt
%matplotlib inline
Person¶
In [4]:
# people from Mimesis - Fake Data Generator
l.person()
Out[4]:
In [33]:
# multiple records of person with locale
l.people(count=5, locale='en')
Out[33]:
In [34]:
# Visualize people
people = l.people(count=50, locale='en')
people['gender'].value_counts().plot(kind='bar');
In [35]:
people['age'].hist();
In [36]:
people['occupation'].value_counts().plot(kind='bar');
In [37]:
people['university'].value_counts().plot(kind='bar');
Company¶
In [13]:
# company
l.company()
Out[13]:
In [17]:
# Multiple companies
l.companies(count=5)
Out[17]:
In [39]:
# Visualize comapanies
companies = l.companies(count=50)
companies.columns.values
Out[39]:
In [41]:
companies['exchange'].value_counts().plot(kind='bar');
In [44]:
companies['industry'].value_counts().plot(kind='bar');
Financial¶
In [57]:
[l.ticker(country='us') for i in range(10)]
Out[57]:
In [56]:
[l.currency() for i in range(10)]
Out[56]:
In [59]:
l.trades(count=5)
Out[59]:
In [63]:
# Visualization
trades = l.trades(count=50)
trades['price'].hist(bins=50).plot();
In [66]:
trades['sector'].value_counts().plot(kind='bar');
In [69]:
### General Purpose
l.superstore(count=5)
Out[69]:
In [75]:
# Visualization
superstore=l.superstore(count=50)
superstore['Country'].value_counts().plot(kind='bar');
In [74]:
superstore['Profit'].plot(kind='hist');
In [77]:
superstore['Sales'].plot(kind='hist');
In [78]:
superstore['State'].value_counts().plot(kind='bar');
Cufflinks Data¶
In [93]:
import cufflinks as cf
from plotly.offline import download_plotlyjs, init_notebook_mode
cf.go_offline()
init_notebook_mode()
Area¶
In [94]:
l.area().head()
Out[94]:
In [95]:
l.area().iplot(kind='area', fill=True)
Bar¶
In [96]:
l.bar().head()
Out[96]:
In [97]:
l.bar().iplot(kind='bar')
Box¶
In [98]:
l.box().head()
Out[98]:
In [99]:
l.box().iplot(kind='box')
Comments
Comments powered by Disqus